package thread;

public class Demo18 {
    private static int count = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 50000; i++) {
                count++;
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 50000; i++) {
                count++;
            }
        });
        t1.start();
        t2.start();
        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(count); // 理论上可以小于50000（最小是2） 不过实际上基本是大于50000
        // 在t1 load了之后 t2一直加到49999 然后t1加并覆盖，接着 t2 load t1加到50000 然后t2覆盖就可以实现   

    }
}
